﻿<navigation:Page x:Class="ShopOnline.Views.ViewOrders" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="750" d:DesignHeight="295"
           xmlns:local="clr-namespace:ShopOnline"                 
           Title="Orders" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <UserControl.Resources>
        <local:ConvertSelectionToBool x:Key="BoolConverter" />
    </UserControl.Resources>
    <toolkit:BusyIndicator Name="busyIndicator">
        <Grid x:Name="LayoutRoot">
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" 
                           Text="Filter by status:" VerticalAlignment="Top" />
            <ComboBox Height="23" HorizontalAlignment="Left" Margin="106,8,0,0" 
                        Name="comboBoxStatuses" VerticalAlignment="Top" Width="120" />
            <Button Content="Filter" Height="23" HorizontalAlignment="Left" Margin="232,8,0,0" 
                        Name="buttonFilter" VerticalAlignment="Top" Width="75"
                        IsEnabled="{Binding ElementName=comboBoxStatuses, Mode=TwoWay, Path=SelectedItem,
                        Converter={StaticResource BoolConverter}}" Click="buttonFilter_Click" />
            <sdk:DataGrid AutoGenerateColumns="False" Height="146" HorizontalAlignment="Left" Margin="12,98,0,0" 
                          Name="dataGridOrders" VerticalAlignment="Top" Width="696" CanUserSortColumns="False">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="Customer name" Binding="{Binding CustomerName}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Address" Binding="{Binding Address}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Phone" Binding="{Binding Phone}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="E-mail" Binding="{Binding Email}" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Header="Status" Binding="{Binding OrderStatuse.Status}" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Header="Date" Binding="{Binding Date,StringFormat=D}" IsReadOnly="True" />
                    <sdk:DataGridTemplateColumn Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>                                
                                <HyperlinkButton Width="80" Content="Chage status" Click="HyperlinkButton_Click"></HyperlinkButton>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
            <sdk:DataPager Height="26" HorizontalAlignment="Left" Margin="12,250,0,0" Name="dataPagerOrders" 
                           PageSize="5" VerticalAlignment="Top" Width="696" />
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,77,0,0" Name="textBlockResult" 
                       VerticalAlignment="Top" />
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="8,41,0,0" 
                       Text="Filter by order:" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="106,37,0,0" Name="textBoxOrderID" 
                     VerticalAlignment="Top" Width="120" TextChanged="textBoxOrderID_TextChanged" />
            <Button Content="Find" Height="23" HorizontalAlignment="Left" Margin="232,37,0,0" IsEnabled="False"
                    Name="buttonFind" VerticalAlignment="Top" Width="75" Click="buttonFind_Click" />
        </Grid>
    </toolkit:BusyIndicator>
</navigation:Page>
